package com.tbit.uqbike.client.aop;

import com.tbit.uqbike.client.constant.AdaPayConstant;
import com.tbit.uqbike.client.constant.SystemConstant;
import com.tbit.uqbike.client.dao.core.AdaPayConfigDao;
import com.tbit.uqbike.client.pojo.newEntity.AdaPayConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author: chen
 * @Description:
 * @Date: 创建于 11:44 2023/5/8
 */
@Component
@Order(1)
@Slf4j
public class CashConfigInitHandler implements ApplicationRunner {


    @Autowired
    private AdaPayConfigDao adaPayConfigDao;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        List<AdaPayConfig> adaPayConfigs = adaPayConfigDao.getAll();
        if (!adaPayConfigs.isEmpty()) {
            String url = SystemConstant.CASH_SERVICE_URL + "/payment/initAdaPayConfig";
            for (AdaPayConfig adaPayConfig : adaPayConfigs) {
                /**第三方注册*/
                //HttpUtil.post(url,"");
                AdaPayConstant.adaPayConfigMap.put(adaPayConfig.getAccountId() + "." + adaPayConfig.getPay_channel(), adaPayConfig);
            }
        }
        log.info("服务初始化" + adaPayConfigs.size());
    }


}
